import { http } from '@/utils/http'

let FixApi = ''
if (process.env.NODE_ENV == 'development') {
  FixApi = '/workorder' //开发环境
} else {
  FixApi = '/workorder' //生产环境
}

/**
 * 服务商创建工单
 */
export const serviceProviderSubmit = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/submit`,
    data,
  })
}
/**
 * 工单数量统计
 */
export const woCount = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/workOrderCount`,
    data,
  })
}
/**
 * 工单列表
 */
export const serviceProviderGetWoList = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/list`,
    data,
  })
}
/**
 * 工单详情
 */
export const woInfo = (data: any) => {
  return http({
    method: 'GET',
    url: `${FixApi}/app/engineer/wo/detail`,
    data,
  })
}
/**
 * 工单资产列表(产品列表)
 */
export const woAssetList = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/assetList`,
    data,
  })
}

/**
 * 更新工单资产
 */
export const updateAsset = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/updateAsset`,
    data,
  })
}
/**
 * 工单工程师列表(产品列表)
 */
export const getWoEngineerList = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/getEngineerList`,
    data,
  })
}
/**
 * 查询工单关联单据
 */
export const getWoRelatedList = (data: any) => {
  return http({
    method: 'GET',
    url: `${FixApi}/wo/getWoRelatedList`,
    data,
  })
}
/**
 * 拒单
 */
export const woReject = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/wo/reject`,
    data,
  })
}
/**
 * 工程师预约
 */
export const engineerAppointment = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/engineerAppointment`,
    data,
  })
}

/**
 * 取消工单
 */
export const WoCancel = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/cancel`,
    data,
  })
}
/**
 * 特殊费用申请
 */
export const engineerAddSpecialExpenses = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/special/engineerAddSpecialExpenses`,
    data,
  })
}
/**
 * 分派工程师
 */
export const manualAssignEngineer = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/wo/manualAssignEngineer`,
    data,
  })
}

/**
 * 签到
 */
export const checkIn = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/checkIn`,
    data,
  })
}
/**
 * 异常签到
 */
export const abnormalSignIn = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/abnormalSignIn`,
    data,
  })
}

/**
 * 获取工单中资产的故障信息
 * @data woAssetId
 */
export const getAssetFaults = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/getWoAssetFault`,
    data,
  })
}
/**工单资产添加故障
 * @data
 */
export const addAssetFault = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/addWoAssetFault`,
    data,
  })
}
/**
 * @data 更新工单资产
 *
 */
export const updateAssetFault = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/updateWoAssetFault`,
    data,
  })
}

/**
 * 删除工单资产故障
 * @data
 */
export const deleteAssetFault = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/deleteWoAssetFault`,
    data,
  })
}
/**
 * 添加工单备件
 */
export const insertWoPart = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/insertWoPart`,
    data,
  })
}
/**
 * 工单备件查询
 */
export const getWoPartList = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/getWoPartList`,
    data,
  })
}
/**
 * 根据产品小类和故障小类查询指导说明书
 */
export const FaultReasonList = (data: any) => {
  return http({
    method: 'POST',
    url: `/system/productFault/selectFaultReasonList`,
    data,
  })
}
/**
 * 提交服务完工
 */
export const submitCompletion = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/submitCompletion`,
    data,
  })
}

/**
 * 提交服务完工
 */
export const temporaryServiceCompletion = (data: any) => {
  return http({
    method: 'POST',
    url: `${FixApi}/app/engineer/wo/temporaryServiceCompletion`,
    data,
  })
}
/**
 * 上传文件回显&&图片回显&&视频回显
 */
export const returnFile = (data: any) => {
  return http({
    method: 'POST',
    url: `/system/file/selectFileItemRelation`,
    data,
  })
}
/**
 * 删除文件回显
 */
export const deleteFileItemRelation = (data: any) => {
  return http({
    method: 'POST',
    url: `/system/file/deleteFileItemRelation`,
    data,
  })
}
/**
 * PC端查询工单详情 提交后的详情
 */
export const selectPcWoCaseInfo = (data: any) => {
  return http({
    method: 'GET',
    url: `${FixApi}/wo/selectPcWoCaseInfo`,
    data,
  })
}
/**
 * 获取归还单列表
 */
export const getObtainReturnList = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/obtainReturn/getObtainReturnList`,
    data,
  })
}
/**
 * 查询待归还备件列表
 */
export const getObtainToBeReturnList = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/obtainReturn/getObtainToBeReturnList`,
    data,
  })
}
/**
 * 查询待归还备件列表
 */
export const listByPart = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/inventory/listByPart`,
    data,
  })
}
/**
 * 查询备件使用订单列表
 */
export const requisitionList = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/receive/list`,
    data,
  })
}

/**
 * 添加归还单
 */
export const addObtainReturn = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/obtainReturn/add`,
    data,
  })
}
/**
 * 领用备件列表
 */
export const mdmSparePartsList = (data: any) => {
  return http({
    method: 'POST',
    url: `/system/mdmSpareParts/list `,
    data,
  })
}
/**
 * 领用单-根据登陆人获取服务网点信息
 */
export const getServicePointInfo = () => {
  return http({
    method: 'GET',
    url: `/part/receive/getServicePointInfo`,
    // data,
  })
}
/**
 * 领用单-保存
 */
export const saveReceive = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/receive/save`,
    data,
  })
}
/**
 * 领用单-明细保存
 */
export const saveReceiveDetail = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/receive/saveDetail`,
    data,
  })
}
/**
 * 领用单-提交
 */
export const submitReceiveDetail = (data: any) => {
  return http({
    method: 'GET',
    url: `/part/receive/submit`,
    data,
  })
}
/**
 * 领用单-详情
 */
export const getReceiveDetial = (data: any) => {
  return http({
    method: 'GET',
    url: `/part/receive/getDetailById`,
    data,
  })
}
/**
 * 领用单-收货
 */
export const batchReceipt = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/pmReceipt/batchReceipt`,
    data,
  })
}
/**
 * 领用单-欠料列表
 */
export const listOweDetail = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/receive/listOweDetail`,
    data,
  })
}
/**
 * 发货单 列表查询
 */
export const listShipment = (data: any) => {
  return http({
    method: 'POST',
    url: `/part/ship/listShipment`,
    data,
  })
}
/**
 * 发货单 开始拣货
 */
export const shipmentPickStart = (data: any) => {
  return http({
    method: 'POST',
    // url: `/part/ship/shipmentPickStart`,
    url: `/part/ship/shipmentAccept`,
    data,

  })
}
/**
 * 发货单 开始拣货
 */
export const shipmentAccept = (data: any) => {
  return http({
    method: 'GET',
    url: `/part/ship/shipmentAccept`,
    data,
  })
}
/**
 * 发货单 完成拣货
 */
export const shipmentPickFinish = (data: any) => {
  return http({
    method: 'GET',
    url: `/part/ship/shipmentPickFinish`,
    data,
  })
}

